import { defineStore } from 'pinia'
import { ref } from 'vue'
import { userGetInfoService } from '@/api/user.js'

export const useUserStore = defineStore(
  'big-use',
  () => {
    const token = ref()
    const setToken = (newToken) => {
      token.value = newToken
    }
    const removeToken = () => {
      token.value = ''
    }
    const info = ref({})
    const getInfo = async () => {
      const res = await userGetInfoService()
      info.value = res.data.data
    }
    const setInfo = () => {
      info.value = ''
    }
    return {
      token,
      setToken,
      removeToken,
      info,
      getInfo,
      setInfo
    }
  },
  {
    persist: true
  }
)
